<?
include("../../config/config.php");
$identifier = array_key_exists("id",$_GET)?$_GET["id"]:"";
$id_log = "$identifier";
$id_site = "";
$id_uagent = "";
$id_charset = "";
$id_lang = "";
$id_page = "";
$id_query = "";
$ip4 = "";
$ip6 = "";
$timestamp = "";

if ($identifier != ""){
	// EDIT ITEM
	$action = "EDITAR";

	$DM->loadClass("tracker","log");
	$object_log = new log();
	$object_log->id_log = $identifier;
	$object_log->getById();
	$id_log = $object_log->id_log;
	$id_site = $object_log->id_site;
	$id_uagent = $object_log->id_uagent;
	$id_charset = $object_log->id_charset;
	$id_lang = $object_log->id_lang;
	$id_page = $object_log->id_page;
	$id_query = $object_log->id_query;
	$ip4 = $object_log->ip4;
	$ip6 = $object_log->ip6;
	$timestamp = $object_log->timestamp;

}
?>

<HEAD>
	<script>
		function replaceSubstring(inputString, fromString, toString) {
			var temp = inputString;
			if (fromString == "") {
				return inputString;
			}
			if (toString.indexOf(fromString) == -1) {
				while (temp.indexOf(fromString) != -1) {
					var toTheLeft = temp.substring(0, temp.indexOf(fromString));
					var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
					temp = toTheLeft + toString + toTheRight;
				}
			} else {
				var midStrings = new Array("~", "`", "_", "^", "#");
				var midStringLen = 1;
				var midString = "";
				while (midString == "") {
					for (var i=0; i < midStrings.length; i++) {
						var tempMidString = "";
						for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
						if (fromString.indexOf(tempMidString) == -1) {
							midString = tempMidString;
							i = midStrings.length + 1;
						}
					}
				}
				while (temp.indexOf(fromString) != -1) {
					var toTheLeft = temp.substring(0, temp.indexOf(fromString));
					var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
					temp = toTheLeft + midString + toTheRight;
				}
				while (temp.indexOf(midString) != -1) {
					var toTheLeft = temp.substring(0, temp.indexOf(midString));
					var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
					temp = toTheLeft + toString + toTheRight;
				}
			}
			return temp;
		}
		
		function showImage(fild){
			theImageObtheFieldToCheckect = eval("document."+fild+"_img");
			theFieldToCheck = document.getElementById(fild);
			theImageObtheFieldToCheckect.src='images/midiaCenter/semNada.gif'
			if (theFieldToCheck.value.indexOf(".ppt")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_download.gif';
			if (theFieldToCheck.value.indexOf(".mp3")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_audios.gif';
			if (theFieldToCheck.value.indexOf(".theFieldToCheckpg")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_image.gif';
			if (theFieldToCheck.value.indexOf(".zip")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_download.gif';
			if (theFieldToCheck.value.indexOf(".swf")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_videos.gif';
		}
		
		function buildImages(fild){
			theImageObtheFieldToCheckect = eval("document."+fild+"_img");
			theFieldToCheck = document.getElementById(fild+"_old");
				theImageObtheFieldToCheckect.src='images/midiaCenter/semNada.gif';
			if (theFieldToCheck.value.indexOf(".ppt")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_download.gif';
			if (theFieldToCheck.value.indexOf(".mp3")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_audios.gif';
			if (theFieldToCheck.value.indexOf(".theFieldToCheckpg")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_image.gif';
			if (theFieldToCheck.value.indexOf(".zip")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_download.gif';
			if (theFieldToCheck.value.indexOf(".swf")>-1)
				theImageObtheFieldToCheckect.src='images/midiaCenter/big_videos.gif';
		}
		
		function checkFilled(){
			mySubmit();
		}
	</script>
	<link href="../../resource/includes/css/admin.css" type="text/css" rel="stylesheet" rev="stylesheet" />
</HEAD>
<body bgcolor='#FFFFFF' onload="">	<form action="log.process.php" method="POST" enctype="multipart/form-data" name="cont">
	<table width='500' cellpadding="3" cellspacing="1" bgcolor="#efefef">
		<tr>
			<td class='titleTd' bgcolor='#ffffff'>LOG</td>
			<td class='titleTd' bgcolor='#ffffff'><font style='font-wheight:bolder;font-size:11px;'><?=$action?></font>
				<input type="hidden" name="id_log" value="<?=$id_log?>">
			</td>
		</tr>
		<tr>
			<td colspan="2" class='titleTd' bgcolor='#ffffff'>TITLE TR</td>
		</tr>
		<tr>
			<td colspan="2" height="20">&nbsp;</td>
		</tr>
		<tr>
			<td class='line1'>ID</td>
			<td class='line1'><input type="text"   size="10" class='inputClass' name="id_log" value="<?=$id_log?>"></td>
		</tr>
		<tr>
			<td class='line2'>id_site</td>
			<td class='line2'><input type="text"   size="10" class='inputClass' name="id_site" value="<?=$id_site?>"></td>
		</tr>
		<tr>
			<td class='line1'>id_uagent</td>
			<td class='line1'><input type="text"   size="10" class='inputClass' name="id_uagent" value="<?=$id_uagent?>"></td>
		</tr>
		<tr>
			<td class='line2'>id_charset</td>
			<td class='line2'><input type="text"   size="10" class='inputClass' name="id_charset" value="<?=$id_charset?>"></td>
		</tr>
		<tr>
			<td class='line1'>id_lang</td>
			<td class='line1'><input type="text"   size="10" class='inputClass' name="id_lang" value="<?=$id_lang?>"></td>
		</tr>
		<tr>
			<td class='line2'>id_page</td>
			<td class='line2'><input type="text"   size="10" class='inputClass' name="id_page" value="<?=$id_page?>"></td>
		</tr>
		<tr>
			<td class='line1'>id_query</td>
			<td class='line1'><input type="text"   size="10" class='inputClass' name="id_query" value="<?=$id_query?>"></td>
		</tr>
		<tr>
			<td class='line2'>ip4</td>
			<td class='line2'><input type="text"  MAXLENGTH="20"  style="width:60px;" class='inputClass' name="ip4" value="<?=$ip4?>"></td>
		</tr>
		<tr>
			<td class='line1'>ip6</td>
			<td class='line1'><input type="text"  MAXLENGTH="60"  style="width:180px;" class='inputClass' name="ip6" value="<?=$ip6?>"></td>
		</tr>
		<tr>
			<td class='line2'>timestamp</td>
			<td class='line2'><input type="text"   size="10" class='inputClass' name="timestamp" value="<?=$timestamp?>"></td>
		</tr>
		<tr>
			<td colspan="2" class="line1" align='right'><input type="button" value="CANCELAR" class='minorAction' onclick="history.go(-1);">&nbsp;<input type="button" value="SALVAR" class='minorAction' onclick="checkFilled();"></td>
		</tr>
	</table>
</form>
<script type="text/javascript">
	function mySubmit() {
		document.cont.submit();
	};
</script>
</body>